namespace Trader.Trading
{
    using System;
    using System.Collections.Generic;
    using Analyzing.Interface;
    using BO.Interface;
    using Indicators.Interface;
    using Interface;

    public class Recommendation : IRecommendation
    {
        private readonly DateTime actionDate;
        private readonly IScenarios scenarios;
        private readonly ISignal signal;
        private readonly IStock stock;

        public Recommendation(IStock stock, ISignal signal, IScenarios scenarios, DateTime actionDate)
        {
            this.stock = stock;
            this.signal = signal;
            this.scenarios = scenarios;
            this.actionDate = actionDate;
        }

        #region IRecommendation Members

        public ISignal Signal
        {
            get { return signal; }
        }

        public IStock Stock
        {
            get { return stock; }
        }

        public decimal? GetCurrentChangePerDay(DateTime dateToCheck)
        {
            decimal baseQuote = stock.Quotes[actionDate].Closing;

            var changesToDate = new List<decimal>();
            for (DateTime date = actionDate; date <= dateToCheck; date += TimeSpan.FromDays(1))
            {
                changesToDate.Add(stock.Quotes[date].Closing/baseQuote - 1);
            }

            return scenarios.GetValuePerDay(changesToDate);
        }

        #endregion
    }
}